home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* The Opus Computer-Based Conversation System */
- /* (c) Copyright 1987, Wynn Wagner III, All Rights Reserved */
- /* */
- /* YOOHOO is a trademark of Wynn Wagner III */
- /* */
- /* YOOHOO-YOOHOO/2U2 is */
- /* Copyright 1987, Wynn Wagner III, All Rights Reserved */
- /* */
- /* This module was written by W.Wagner III */
- /* with modifications done by Vince Perriello */
- /* and more modifications done by Bob Hartman */
- /* */
- /* */
- /* BinkleyTerm "YooHoo" Processor */
- /* */
- /* */
- /* This module is a very simple FOSSIL-based terminal emulator. It is */
- /* provided for your information only. You will find routines that need */
- /* to be coded and identifiers to be resolved. It has been previously */
- /* known as "OpusLink" and "OConnect". The use of the name "BinkleyTerm" */
- /* does not preclude the possibility that another "OpusLink" or "OConnect" */
- /* could be released. */
- /* */
- /* There is absolutely no guarantee that anything here will work. If you */
- /* break this routine, you own both pieces. */
- /* */
- /* USAGE: You may use this material in any program with no obligation */
- /* as long as there is no charge for your program. For more */
- /* information about commercial use, contact the "OPUSinfo HERE" */
- /* BBS (124/111). */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
-
- #define WAZOO_SECTION
- #define MATRIX_SECTION
- #define isBITBRAIN 0x1b
-
- #include "com.h"
- #include "xfer.h"
-
- extern char *CRC_msg;
- extern char *SHRT_msg;
- extern char *FUBAR_msg;
- extern char *TIME_msg;
- extern char *IDUNNO_msg;
- extern char *KBD_msg;
- extern char *local_CEOL;
-
- extern int un_attended;
- extern int fullscreen;
-
- char no_zapzed = 0;
- int hup = 0;
-
-
- int send_YOOHOO(int);
- int get_YOOHOO();
- int send_Hello();
-
-
-
- /*--------------------------------------------------------------------------*/
- /* SEND YOOHOO */
- /*--------------------------------------------------------------------------*/
- int send_YOOHOO(instigator)
- int instigator;
- begin
- char *sptr = NULL;
-
- if (un_attended && fullscreen)
- {
- gotoxy (0, 16);
- }
- set_xy( "YooHoo " );
- if (!send_Hello())
- begin
- sptr = "No Send";
- goto nope;
- end
-
- if (instigator)
- begin
- if (TIMED_READ(12)==YOOHOO) return get_YOOHOO(0);
-
- status_line("!No YOOHOO/2U2");
- set_xy(NULL);
- end
- sptr = IDUNNO_msg;
-
- nope:
- if (sptr) message(sptr);
- return 0;
-
- end
-
-
-
-
- /*--------------------------------------------------------------------------*/
- /* TRANSMIT HELLO PACKET */
- /*--------------------------------------------------------------------------*/
- int send_Hello()
- begin
- int i;
- struct _Hello Hello;
- byte *sptr;
- word crc;
- word num_errs = 0;
-
-
- /*--------------------------------------------------------------------*/
- /* Setup HELLO structure */
- /*--------------------------------------------------------------------*/
- memset( (char *)&Hello, 0, sizeof(struct _Hello) );
-
- Hello.signal = 'o';
- Hello.hello_version = 1;
-
- Hello.product = isBITBRAIN;
- Hello.product_maj = BINK_MAJVERSION;
- Hello.product_min = BINK_MINVERSION;
-
- strncpy( Hello.my_name, ctl.system_name, 58 );
- Hello.my_name[59] = '\0';
-
- strncpy( Hello.sysop, ctl.sysop, 19 );
- Hello.sysop[19] = '\0';
-
- Hello.my_zone = ctl.our_zone;
- Hello.my_net = ctl.alias[0].net;
- Hello.my_node = ctl.alias[0].node;
-
- Hello.capabilities = (no_zapzed)?Y_DIETIFNA:Y_DIETIFNA|ZED_ZAPPER;
-
- if (n_getpassword( remote_net, remote_node ))
- begin
- strncpy( Hello.my_password, remote_password, 7 );
- end
- else
- begin
- Hello.my_password[0] = '\0';
- end
- Hello.my_password[6] = '\0';
-
- if (ctl.matrix_mask&TAKE_REQ)
- Hello.capabilities |= WZ_FREQ;
-
-
-
-
- /*--------------------------------------------------------------------*/
- /* Disable handshaking and ^C/^K handling */
- /*--------------------------------------------------------------------*/
- XON_DISABLE();
- brk_disable();
-
- /*--------------------------------------------------------------------*/
- /* Send the packet. */
- /* Load outbound buffer quickly, and get modem busy sending. */
- /*--------------------------------------------------------------------*/
-
- send:
-
- SENDBYTE( 0x1f );
-
- if ( (num_errs++) > 10 )
- begin
- message(FUBAR_msg);
- return 0;
- end
-
- sptr = (char *)(&Hello);
- SENDCHARS (sptr, 128, 1);
- /*
- for(i=0; i<128; i++ ) SENDBYTE( sptr[i] );
- */
-
-
- /*--------------------------------------------------------------------*/
- /* Clear inbound ring buffer */
- /*--------------------------------------------------------------------*/
- CLEAR_INBOUND();
-
-
- /*--------------------------------------------------------------------*/
- /* Calculate CRC while modem is sending its buffer */
- /*--------------------------------------------------------------------*/
- for(crc=i=0;i<128;i++)
- begin
- crc = xcrc(crc,(byte )sptr[i]);
- end
-
- CLEAR_INBOUND();
-
- SENDBYTE( crc>>8 );
- SENDBYTE( crc&0xff );
-
-
- while(1)
- switch( i=TIMED_READ(17) )
- begin
- case ACK :
- return 1;
-
- case '?' : message("drats");
- goto send;
-
- case ENQ : break;
-
- default : if (i>0) /* Could just be line noise */
- begin
- cprintf("[%x] ",i);
- break;
- end
- /* If we didn't get anything, that is bad */
- return 0;
- end
-
- end /* Send Hello */
-
-
-
-
- /*--------------------------------------------------------------------------*/
- /* GET YOOHOO */
- /*--------------------------------------------------------------------------*/
- int get_YOOHOO( plan_to_send_too )
- int plan_to_send_too;
- begin
- int i;
- int c;
- struct _Hello Hello;
- byte *sptr;
- byte num_errs = 0;
- int timer_val;
- word crc;
- word lsb;
- word msb;
- long t,timerset();
-
- /* To get here, Opus has already read the YOOHOO */
- hup = 0;
- sptr = NULL;
- if (remote_capabilities>0)
- begin
- return 1;
- end
-
- /*--------------------------------------------------------------------*/
- /* Clean up any mess that may be around */
- /*--------------------------------------------------------------------*/
- CLEAR_OUTBOUND();
- CLEAR_INBOUND();
- XON_DISABLE();
- brk_disable();
-
-
- /*--------------------------------------------------------------------*/
- /* Get the Hello structure */
- /*--------------------------------------------------------------------*/
-
- SENDBYTE(ENQ); /* Let the other system know we're curious. */
- if (un_attended && fullscreen)
- {
- gotoxy (0, 17);
- }
- set_xy("YooHoo/2U2 ");
-
- recv:
- i = 0;
- while(1)
- begin
-
- if (sptr)
- begin
- message(sptr);
- sptr = NULL;
- end
-
- if (((KEYPRESS()) and (READKB()==27)))
- begin
- sptr = KBD_msg;
- goto failed;
- end
-
- if ((c=TIMED_READ(12)) == 0x1f) goto loop;
-
- if (!CARRIER)
- begin
- sptr = CARRIER_msg;
- goto failed;
- end
-
- if (c<0)
- begin
- if ((i++) > 7)
- begin
- sptr = TIME_msg;
- goto failed;
- end
- end
- else
- begin
- if (i>1) sptr = "Scratching head";
- else
- begin
- t = timerset(1000);
- while( (PEEKBYTE()>=0)&&(CARRIER)&&(!timeup(t)) )
- if (MODEM_IN()==0x1f) goto loop;
- i = 1;
- end
- CLEAR_INBOUND();
- SENDBYTE(ENQ);
- end
-
- end /* while */
-
-
- loop:
-
- sptr = (char *)(&Hello);
- for(i=0; i<128; i++ )
- begin
- if ( (c=TIMED_READ(17)) < 0 )
- begin
- sptr = TIME_msg;
- goto failed;
- end
- else sptr[i] = c;
- end
-
-
- /*--------------------------------------------------------------------*/
- /* Calculate CRC */
- /*--------------------------------------------------------------------*/
- begin
- for(crc=i=0;i<128;i++)
- begin
- crc = xcrc(crc,(byte )sptr[i]);
- end
-
- if (!CARRIER)
- begin
- sptr = CARRIER_msg;
- goto failed;
- end
- else sptr = NULL;
-
- msb = TIMED_READ(3);
- lsb = TIMED_READ(3);
-
- if ((lsb<0)||(msb<0))
- begin
- sptr = SHRT_msg;
- goto err;
- end
- else if ( ((msb<<8)|lsb) != crc )
- begin
- sptr = CRC_msg;
-
- err: if ( (num_errs++) > 10 )
- begin
- sptr = FUBAR_msg;
- goto failed;
- end
-
- CLEAR_INBOUND();
- SENDBYTE('?');
- goto recv;
-
- end
- end
-
-
- Hello.my_name[42] = '\0';
- Hello.sysop[19] = '\0';
- opus_maj = Hello.product_maj;
- opus_min = Hello.product_min;
- remote_zone = Hello.my_zone;
- remote_net = Hello.my_net;
- remote_node = Hello.my_node;
- remote_point = Hello.my_point;
- remote_capabilities = (Hello.capabilities)|Y_DIETIFNA;
-
-
- status_line("*%s (%u:%u/%u.%u)",
- Hello.my_name,
- remote_zone,
- remote_net,
- remote_node,
- remote_point);
-
- switch (Hello.product)
- {
- case isBITBRAIN:
- status_line ("*Remote Uses BinkleyTerm Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- case isOPUS:
- status_line ("*Remote Uses Opus Version %d.%d", Hello.product_maj,
- (Hello.product_min == 48) ? 0 : Hello.product_min);
- break;
- case isFIDO:
- status_line ("*Remote Uses Fido-Something Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- case isSPARK:
- status_line ("*Remote Uses Spark-Something Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- case isSEA:
- status_line ("*Remote Uses SEA-Something Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- case isHENK:
- status_line ("*Remote Uses Dutchie-Something Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- case isTABBIE:
- status_line ("*Remote Uses Tabbie-Something Version %d.%d",
- Hello.product_maj, Hello.product_min);
- break;
- default:
- status_line ("*Remote Uses Program '%02x' Version %d.%d",
- Hello.product, Hello.product_maj, Hello.product_min);
- break;
- }
-
- if (Hello.sysop[0])
- begin
- Hello.sysop[19] = '\0';
- strcpy( remote_sysop, Hello.sysop );
- status_line( ":Sysop: %s", remote_sysop );
- end
-
- if (un_attended && fullscreen)
- begin
- gotoxy (0,19);
- end
-
- if (n_getpassword( Hello.my_net, Hello.my_node ))
- begin
- if (n_password(remote_password,Hello.my_password))
- begin
- goto failed;
- end
- end
-
- CLEAR_INBOUND();
-
- SENDBYTE(ACK);
- SENDBYTE(YOOHOO);
-
-
- if (plan_to_send_too)
- begin
-
- for(i=0; (CARRIER) and (i<10); i++)
- begin
- if ((c=TIMED_READ(5))==ENQ)
- begin
- n_getpassword(Hello.my_net,Hello.my_node);
- return send_Hello()? 1: (b_init(),0);
- end
- else
- begin
- if (c>0)
- begin
- message(NULL);
- cprintf("[%x] ",c);
- CLEAR_INBOUND();
- end
- SENDBYTE(YOOHOO);
- end
- end
-
- sptr = FUBAR_msg;
- goto failed;
-
- end
-
- return 1;
-
- failed:
-
- hup = 1;
- message(sptr);
- b_init();
- return 0;
-
- end /* get_yoohoo */
-
-
-
- /* END OF FILE: n_yoohoo.c */
-